package com.ssy.lingxi.settle.accounts.model.constant;

import com.ssy.lingxi.common.language.LanguageHolder;
import com.ssy.lingxi.dto.model.constant.SettlementHelpEnum;

import java.util.Arrays;

/**
 * 请款单内部状态
 * @author Saske
 * @date 2021/12/19
 * @version 2.0.0
 */
public enum  ApplyAmountInnerStatusEnum {

    /**
     * 待提交审核
     */
    TO_SUBMIT(1, "待提交审核"),

    /**
     * 待付款
     */
    TO_PAY(2, "待付款"),

    /**
     * 已付款
     */
    PAID(3, "已付款");

    private final Integer code;
    private final String message;

    ApplyAmountInnerStatusEnum(Integer code, String message) {
        this.code = code;
        this.message = message;
    }

    public Integer getCode() {
        return code;
    }

    public String getMessage() {
        return LanguageHolder.getName(this.getDeclaringClass(), this.getCode());
    }

    /**
     * 根据外部状态枚举值获得外部状态名称
     * @param code 外部状态枚举值
     * @return 外部状态名称
     */
    public static String getNameByCode(Integer code) {
        ApplyAmountInnerStatusEnum statusEnum = Arrays.stream(ApplyAmountInnerStatusEnum.values()).filter(e -> e.getCode().equals(code)).findFirst().orElse(null);
        return statusEnum == null ?  SettlementHelpEnum.UNKNOWN.getMessage() : statusEnum.getMessage();
    }
}
